home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWDebug / Include / FWPriDeb.h < prev    next >
Encoding:
Text File  |  1995-11-08  |  4.1 KB  |  159 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPriDeb.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWENVDEF_H
  11. #include "FWEnvDef.h"
  12. #endif
  13.  
  14. #if !defined(FWPRIDEB_H) && defined(FW_DEBUG)
  15. #define FWPRIDEB_H
  16.  
  17. #ifndef FWDBGSTR_H
  18. #include "FWDbgStr.h"
  19. #endif
  20.  
  21. #if FW_LIB_EXPORT_PRAGMAS
  22. #pragma lib_export on
  23. #endif
  24.  
  25. class FW_CLASS_ATTR FW_CDebugConsole
  26. {
  27. public:
  28.  
  29.     virtual ~FW_CDebugConsole();
  30.         // Destructor, does nothing.
  31.     
  32.     FW_CDebugConsole();
  33.         // Constructor, does SetConsole(0).
  34.  
  35.     static FW_CDebugConsole* GetConsole();
  36.         // Get the currently installed debug console
  37.         
  38.     static FW_CDebugConsole* SetConsole(FW_CDebugConsole* console);
  39.         // Install a new debug console.
  40.         // The prior debug console is returned.
  41.  
  42.     static void LogMessage(const char* message);
  43.         // Display the message, preferably without suspending execution.
  44.         
  45.     static void DebugMessage(const char* message);
  46.         // Suspend normal execution and display the message.
  47.         
  48.     static void Debugger();
  49.         // Suspend normal execution without displaying a message
  50.     
  51.     FW_CDebugStream & GetFatalErrorStream();
  52.         // Get the fatal error stream
  53.     
  54.     FW_CDebugStream & GetWarningStream();
  55.         // Get the warning stream
  56.     
  57.     FW_CDebugStream & GetNotificationStream();
  58.         // Get the notification stream
  59.     
  60. protected:
  61.  
  62.     virtual void DoLogMessage(const char* message);
  63.         // Display the message, preferably without suspending execution.
  64.         
  65.     virtual void DoDebugMessage(const char* message);
  66.         // Suspend normal execution and display the message.
  67.         
  68.     virtual void DoDebugger();
  69.         // Suspend normal execution without displaying a message
  70.  
  71.     FW_CDebugStream * fFatalErrorStream;
  72.         // Stream for fatal error messages
  73.  
  74.     FW_CDebugStream * fWarningStream;
  75.         // Stream for warning messages
  76.  
  77.     FW_CDebugStream * fNotificationStream;
  78.         // Stream for notification messages
  79.  
  80. public:
  81.  
  82.     // ----- Internal Methods
  83.  
  84.     static void PrivDebugMessage(const char* message);
  85.         // Hard drop into debugger and display the message.
  86.         
  87.     static void PrivDebugger();
  88.         // Hard drop into debugger without displaying a message
  89.         
  90. private:
  91.     enum { kBufferSize = 100};
  92.         // Size of the buffer for the debug stream
  93.     
  94.     char fBuffer[100];
  95.         // The debug stream buffer
  96.  
  97.     FW_CBufferDebugStream fBufferStream;
  98.         // Buffer stream
  99.         
  100.     FW_CNullDebugStream fNullStream;
  101.         // Null stream
  102.  
  103.     static FW_CDebugConsole *gDebugConsole;
  104.     static FW_CDebugConsole  sDebugConsole;
  105.         // Where to write
  106.  
  107.     FW_CDebugConsole(const FW_CDebugConsole& debugConsole);
  108.     FW_CDebugConsole& operator=(const FW_CDebugConsole& debugConsole);
  109.         // Don't copy instances of this class.
  110. };
  111.  
  112. #define FW_PRIV_DEBUGGER_BREAK() FW_CDebugConsole::PrivDebugger()
  113.  
  114. #define FW_PRIV_DEBUGGER_STRING(message) FW_CDebugConsole::PrivDebugMessage(message)
  115.  
  116. #define FW_PRIV_ASSERT(f) if(!(f)) FW_CDebugConsole::PrivDebugMessage((const char*) #f)
  117.     // If f evaluates to false, drop into the debugger and display f as string.
  118.  
  119. #define FW_DEBUGGER() FW_CDebugConsole::Debugger()
  120.  
  121. #define FW_DEBUG_MESSAGE(message) FW_CDebugConsole::DebugMessage(message)
  122.  
  123. #define FW_LOG_MESSAGE(message) FW_CDebugConsole::LogMessage(message)
  124.  
  125. #define FW_ASSERT(f) if(!(f)) FW_CDebugConsole::DebugMessage((const char*) #f)
  126. //#define FW_ASSERT(f) if(!(f)) FW_CDebugConsole::DebugMessage((const char*) #f)
  127.     // If f evaluates to false, drop into the debug console and display f as string.
  128.  
  129. inline FW_CDebugStream & FW_CDebugConsole::GetFatalErrorStream()
  130. {
  131.     return *fFatalErrorStream;
  132. }
  133.  
  134. inline FW_CDebugStream & FW_CDebugConsole::GetWarningStream()
  135. {
  136.     return *fWarningStream;
  137. }
  138.  
  139. inline FW_CDebugStream & FW_CDebugConsole::GetNotificationStream()
  140. {
  141.     return *fNotificationStream;
  142. }
  143.  
  144. #else
  145.  
  146. #define FW_PRIV_DEBUGGER_BREAK() ((void)0)
  147. #define FW_PRIV_DEBUGGER_STRING(message) ((void)0)
  148. #define FW_PRIV_ASSERT(f) ((void)0)
  149. #define FW_DEBUGGER() ((void)0)
  150. #define FW_DEBUG_MESSAGE(message) ((void)0)
  151. #define FW_LOG_MESSAGE(message) ((void)0)
  152. #define FW_ASSERT(f) ((void)0)
  153.  
  154. #endif
  155.  
  156. #if FW_LIB_EXPORT_PRAGMAS
  157. #pragma lib_export off
  158. #endif
  159.